package test;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import sun.net.www.protocol.jar.JarURLConnection;

public class DemoCLass {
	 public static void main(String[] args) {
		  try {
			Enumeration<URL> urls = DemoCLass.class.getClassLoader().getResources("org.nature".replaceAll("\\.", "/"));
			while (urls.hasMoreElements()) {
				URL nextElement = urls.nextElement();
				String protocol = nextElement.getProtocol();
				System.out.println("type:"+protocol+":"+nextElement.getPath());
				JarURLConnection jarURLConnection = (JarURLConnection) nextElement.openConnection();
				JarFile jarFile = jarURLConnection.getJarFile();
				System.out.println(jarFile.getName());
				if (jarFile != null) {
					Enumeration<JarEntry> jarEntities = jarFile.entries();
					while (jarEntities.hasMoreElements()) {
						JarEntry jarEntity = jarEntities.nextElement();
						String jarEntityName = jarEntity.getName();
						if (jarEntityName.endsWith(".class")) {
							String className = jarEntityName.substring(0, jarEntityName.lastIndexOf("."))
									.replaceAll("/", ".");
							System.out.println(className);
						}
					}
				} 
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
